﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using Common.Library.Files;

namespace Common.Library.Logs
{
    public class FileLog : ILog
    {
        /// <summary>
        /// 日志文件配置地址
        /// </summary>
        private static string LogFileAddr;
        static FileLog()
        {
            LogFileAddr = ConfigurationManager.AppSettings["LogFileAddr"];
            if (string.IsNullOrEmpty(LogFileAddr))
            {
                LogFileAddr = "D://Log.txt";
            }
        }

        /// <summary>
        /// 写入日志
        /// </summary>
        /// <param name="MethodName"></param>
        /// <param name="param"></param>
        /// <param name="ErrorMsg"></param>
        /// <param name="errorType"></param>
        public static void WriteLog(string MethodName, string param, string ErrorMsg, ErrorType errorType)
        {
            string logMsg = $"MethodName : { MethodName }" +
                $"参数信息 : { param }" +
                $"ErrorMsg : { ErrorMsg }" +
                $"ErrorType : { errorType.ToString() }" +
                $"CreateTime : { DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }";
            FileStreamhelper.AppendAllText(LogFileAddr, logMsg);
        }

        public void WriteLog(SystemType systemType, ErrorType errorType, string MethodName, string param, string ErrorMsg)
        {
            throw new NotImplementedException();
        }

    }

}
